﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:Validation="clr-namespace:Rules">
    <Style TargetType="Validation:ValidationStatusControl">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Validation:ValidationStatusControl">
                    <Grid Background="{TemplateBinding Background}">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Valid" >
                                    <Storyboard/>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Error" >
                                    <Storyboard >
                                        <DoubleAnimation
	                                            Storyboard.TargetName="errorImage"
	                                            Storyboard.TargetProperty="Opacity"
	                                            BeginTime="00:00:00" Duration="0:0:1"
	                                            To="1"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="errorImage" 
                                                                       Storyboard.TargetProperty="Visibility"
                                                                       Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="0:0:0"/>
                                </vsm:VisualStateGroup.Transitions>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Image x:Name="errorImage" 
                               Opacity="0"
                               Visibility="Collapsed"
                               Source="/Rules;component/Resources/Error.png"
                               Width="16" 
                               Height="16" />
                        <Popup x:Name="popup">
                            <Border BorderBrush="Black" BorderThickness="1">
                                <Grid Background="Bisque">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Image Source="/Rules;component/Resources/Error.png" Width="16" Height="16" Opacity="1" />
                                    <TextBlock x:Name="text" Margin="5,2,2,2" Grid.Column="1" />
                                </Grid>
                            </Border>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>